#!/usr/bin/python
#Copyright(c) 2008 Tri Tech Information Systems Inc. All Rights Reserved.
#
# Support the generation of boost::python bindings
#

from getopt import getopt, GetoptError
import sys

from pyxx.context import WrapperContext
        
def main( argv ):
    (opts, files) = getopt( argv[1:], "I:M:" )
    src = files[0]

    stdout = sys.stdout
    sys.stdout = sys.stderr

    ctx = WrapperContext()
    for opt, val in opts:
        if '-I' == opt:
            ctx.AddIncludePath( val )
        elif '-M' == opt:
            ctx.module = val

    if not ctx.module:
        raise Exception("A module must be specified!")

    ctx.evaluate(src)
    print >> stdout, ctx.generate()

if __name__ == '__main__':
    main( sys.argv )
